package com.pwt.repository;

import com.pwt.common.ResultPage;
import com.pwt.entity.Images;
import com.pwt.repository.base.DataRepositoryExtension;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author dw
 * @date 2021/12/20 21:06
 * @Description
 */
public class imagesRepositoryExtensionImpl extends DataRepositoryExtension<Images,String> implements imagesRepositoryExtension {
    @Override
    public ResultPage<Images> imagesPage(String name,String startTime,String endTime, Integer page, Integer limit, String severPath) {

        String sql = "select id,file_name,unique_name,suffix_name,('"+severPath+"'+id) as path,create_time,state,station from images where 1=1";
        String cSql = "select count(1) from images where 1=1";
        if(StringUtils.isNotBlank(name)){
            sql+=" and file_name like N'%"+name+"%'";
            cSql+=" and file_name like N'%"+name+"%'";
        }
        if(StringUtils.isNotBlank(startTime)){
            sql+=" and create_time >= '"+startTime+"'";
            cSql+=" and create_time >='"+startTime+"'";
        }
        if(StringUtils.isNotBlank(endTime)){
            sql+=" and create_time <= '"+endTime+"'";
            cSql+=" and create_time <= '"+endTime+"'";
        }

        return super.queryEntityPageBySql(cSql,sql,page-1,limit);
    }
}
